<template>
	<!-- <view>健康课堂</view> -->
	<view>
			<view class="uni-container">
				<uni-table ref="table" :loading="loading" border stripe type="selection" emptyText="暂无更多数据" @selection-change="selectionChange" >
					<uni-tr>
						<uni-th width="150" align="center">专家教授编号</uni-th>
						<uni-th width="150" align="center">直播平台id</uni-th>
						<uni-th width="204" align="center">专家名称</uni-th>
						<uni-th width="204" align="center">粉丝数</uni-th>
					</uni-tr>
					<uni-tr v-for="(item, index) in tableData" :key="index">
						<uni-td>{{ item.statisticsId }}</uni-td>
						<!-- <uni-td>
							<view class="name">{{ item.expertId }}</view>
						</uni-td> -->
						<uni-td align="center">{{ item.liveId }}</uni-td>
						<uni-td align="center">{{ item.expertName }}</uni-td>
						<uni-td align="center">{{ item.expertFans }}</uni-td>
						<uni-td>
							<view class="uni-group">
								<button class="uni-button" size="mini" type="primary" @click="zhibojian">进入直播间</button>
									
							</view>
						</uni-td>
					</uni-tr>
					
				</uni-table>
			</view>
		</view>
</template>

<script>
	export default {
	data() {
			return {
				searchVal: '',
				tableData: [],
				pageSize: 10,
				pageCurrent: 1,
				total: 0,
				loading: false
			}
		},
		onLoad() {
			this.selectedIndexs = []
			this.getData(1)
		},
		methods: {
			zhibojian(){
				location.href="https://localhost:8443/admin.html#"
			},
			selectedItems() {
				return this.selectedIndexs.map(i => this.tableData[i])
			},
			selectionChange(e) {
				console.log(e.detail.index)
				this.selectedIndexs = e.detail.index
			},
			delTable() {
				console.log(this.selectedItems())
			},
			change(e) {
				this.$refs.table.clearSelection()
				this.selectedIndexs.length = 0
				this.getData(e.current)
			},
			search() {
				this.getData(1, this.searchVal)
			},
			getData(pageCurrent, value = '') {
				this.loading = true
				this.pageCurrent = pageCurrent
				uni.request({
					url: 'http://localhost:7000/course/expert/expertlist', 
					pageSize: this.pageSize,
					pageCurrent: pageCurrent,
					value: value,
					method:'POST',
					success: res => {
						console.log(res.data);
						 this.tableData=res.data.data.records
						this.total = res.total
						this.loading = false
					}
				})
			},
		}	
	}
</script>

<style >
	.uni-group {
		display: flex;
		align-items: center;
	}
</style>
